<!DOCTYPE html>
<html>
<head>
	<title>基于ThinkPHP5.1的IP地址查询工具</title>
	<style type="text/css">
	.container{
		width: 80%;
		margin-left: auto;
		margin-right: auto;
		font-family: 微软雅黑;
	}
	.head{
		text-align: center;
		font-size: 26px;
		margin-bottom: 20px;
	}
	.input input{
		padding-left: 10px!important;
		height: 26px;
		line-height: 28px;
		border: 1px solid #DCDCDC;
	}
	.input button{
		background-color: #257BE6;
		color: #fff;
		text-align: center;
		font-size: 14px;
		border: none;
		border-radius: 3px;
		line-height: 30px;
		padding: 0 21px;
		cursor: pointer;
	}
	.input button:hover{
		background-color: #5095EB;
	}
	</style>
</head>
<body>
<div class="container">
	<div class="head">
		基于ThinkPHP5.1的IP地址查询工具
	</div>
	<div class="">
		<a href="/">返回首页</a>
	</div>
	<div class="input">
		<span>请输入IP地址：</span>
		<input type="text" value="{$myip}" placeholder="请输入IP地址">
		<button>查询</button>
	</div>
	<div class="result">

	</div>
</div>
<span class="ipv4" style="display:none;"></span>
<span class="ipv6" style="display:none;"></span>
</body>
<script type="text/javascript" src="/static/js/jquery.min.js"></script>
<script type="text/javascript">
	var ippatt = function(ipv4){
	    var patt = /([0-9]{1,3}(\.[0-9]{1,3}){3})/;//ipv4正则表达式
	    return patt.test(ipv4);
	}
	$(document).ready(function(){
		$(".input").on("click","button",function(){
			var ip_input = $(this).siblings("input").val();
			if(ip_input==null||ip_input.length==0){
				$(".result").prepend("<p>输入IP不能为空</p>");
				return false;
			}
			if(!ippatt(ip_input)){
				$(".result").prepend("<p>IP格式不正确</p>");
				return false;
			}
			$.post("/index/index/ipregion?method=post",{line:ip_input},function(res){
				$(".result").prepend("<p>"+ip_input+" "+res+"</p>");
			})
		})
		$(".input").trigger("click");
	});
</script>
<script type="text/javascript" src="/static/js/rtc_ip.js"></script>
<script type="text/javascript">
getIPs(function(type,value){
	$("."+type).text(value);
});
$(function(){
    var collect = setTimeout(function(){
    	var param = {};
    	param.ipv4 = $(".ipv4").text();
    	param.ipv6 = $(".ipv6").text();
    	param.tag = "ipregion";
    	$.post("https://xinxi.linzening.club/ipv6/ip",param,function(res){
    		console.log(res);
    	});
    },300);
})
</script>
</html>
